package com.xpgk.mvc.productSet;

import java.util.List;

import javax.xml.crypto.Data;

import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Record;
import com.xpgk.annotation.Table;
import com.xpgk.mvc.base.BaseModel;
import com.xpgk.mvc.codeSet.Code;

/**
 * 产品
 */
@SuppressWarnings("unused")
@Table(tableName = Product.table_name)
public class Product extends BaseModel<Product> {

	private static final long serialVersionUID = -7473372625055747548L;

	private static final Log log = Log.getLog(Product.class);

	public static final Product dao = new Product().dao();

	/**
	 * 表名称
	 */
	public static final String table_name = "sb_product";


	
	/**
	 * 字段描述：主键 字段类型：character varying 长度：32
	 */
	public static final String column_ids = "ids";
	/**
	 * 字段描述：产品名称 字段类型：character varying 长度：25
	 */
	public static final String column_name = "name";
	/**
	 * 字段描述：产品编号 字段类型：character varying 长度：32
	 */
	public static final String column_proBh = "proBh";
	/**
	 * 字段描述：类别id 字段类型：character varying 长度：32
	 */
	public static final String column_typeIds = "typeIds";
	
	/**
	 * 字段描述：用途ids 字段类型：character varying 长度：32
	 */
	public static final String column_useIds = "useIds";
	
	/**
	 * 字段描述：产品规格字段类型：character varying 长度：100
	 */
	public static final String column_proSpecification = "proSpecification";
	/**
	 * 字段描述：产品单位字段类型：character varying 长度：10
	 */
	public static final String column_proUnits = "proUnits";
	/**
	 * 字段描述：产品容量 字段类型：character varying 长度：50
	 */
	public static final String column_proCapacity = "proCapacity";
	/**
	 * 字段描述：产品使用经验 字段类型：character varying 长度：50
	 */
	public static final String column_proExperience = "proExperience";
	/**
	 * 字段描述：产品进价 字段类型：character varying 长度：50
	 */
	public static final String column_putPrice = "putPrice";
	/**
	 * 字段描述：产品售价 字段类型：character varying 长度：50
	 */
	public static final String column_outPrice = "outPrice";
	/**
	 * 字段描述：产品状态 字段类型：character 长度：1
	 */
	public static final String column_status = "status";
	/**
	 * 字段描述：添加产品时间 字段类型：Datetime
	 */
	public static final String column_addtime = "addtime";
	/**
	 * 字段描述：禁用产品时间 字段类型：Datetime
	 */
	public static final String column_disabletime = "disabletime";
	/**
	 * 字段描述：1卖品，0非卖品
	 */
	public static final String column_notSell = "notSell";
	/**
	 * 字段描述：该条数据添加人员is  字段类型：character varying 长度：32
	 */
	public static final String column_createId = "createId";
	/**
	 * 字段描述：该条数据添加时间  字段类型：datetime 长度：0
	 */
	public static final String column_createDate = "createDate";
	/**
	 * 字段描述：该条数据更新人员id  字段类型：character varying 长度：100
	 */
	public static final String column_updateId = "updateId";
	/**
	 * 字段描述：该条数据更新时间  字段类型：datetime 长度：0
	 */
	public static final String column_updateDate = "updateDate";
	
	
	
	/**
	 * 字段描述：该条数据更新时间  字段类型：datetime 长度：0
	 */
	public static final String column_orgId = "orgId";
	
	/**
	 * 字段描述：单疗程
	 */
	public static final String dlc_ids = "4777c2c215b6408ab13c1eac4190ce46";
	/**
	 * 字段描述：一疗程
	 */
	public static final String ylc_ids = "27aeb2d41d044394b9b58f6814baa4fa";
	/**
	 * 字段描述：标准疗程
	 */
	public static final String bzlc_ids = "0896ce4d4970455d9184e6dd1ced6a0e";
	/**
	 * 字段描述：膏
	 */
	public static final String g_ids = "daaba791f4104ae98504a1bc421e0d8d";
	/**
	 * 字段描述：精油
	 */
	public static final String jy_ids = "95e2ae17462e4d0eb1dc84bc63bc478a";
	
	
//	/**
//	 * 字段描述：单疗程编号
//	 */
//	public static final String column_dlcBh = "LC002";
//	/**
//	 * 字段描述：标准疗程编号
//	 */
//	public static final String column_bzlcBh = "LC001";
	/**
	 * sqlId : sys.product.column 描述：查询用户，自定义字段和值
	 */
	public static final String sqlId_column = "sys.product.column";
//
//	/**
//	 * sqlId : sys.product.proName 描述：查询产品编号
//	 */
//	public static final String sqlId_proName = "sys.product.proName";
	/**
	 * sqlId : sys.product.selProByIds 描述：根据ids查询产品
	 */
	public static final String sqlId_selProByIds = "sys.product.selProByIds";
	/**
	 * sqlId : sys.product.selProByName 描述：根据ids查询产品
	 */
	public static final String sqlId_selProByName = "sys.product.selProByName";
	/**
	 * sqlId : sys.product.lcPro 描述：查询指定类型的产品列表
	 */
	public static final String sqlId_getProductsByType = "sys.product.getProductsByType";
	/**
	 * sqlId : sys.product.ylc 描述：查询一疗程产品
	 */
	public static final String sqlId_ylc = "sys.product.ylc";
	/**
	 * sqlId : sys.product.nolcpro 描述：查询除疗程外产品
	 */
	public static final String sqlId_nolcpro = "sys.product.nolcpro";
	/**
	 * 描述：分页Select
	 */
	public static final String sqlId_splitPageSelect = "sys.product.splitPageSelect";

	/**
	 * 描述：分页from
	 */
	public static final String sqlId_splitPageFrom = "sys.product.splitPageFrom";
	
	
	/**
	 * 关联查询获取类型类别
	 * @return
	 */
	public Code getType(){
		return Code.cacheGet(this.getStr(Product.column_typeIds));
	}
	
	/**
	 * 关联查询获取部位经验值
	 * @return
	 */
	public List<Record> getPartsExperience(){
		return ProductExperience.dao.findByProIds(this.getPKValue());
	}
	
	
	/**
	 * 获取1疗程
	 * @return
	 */
	public List<Product> getYiLiaoCheng(String proUnits,String proCapacity,String organIds){
		String  sql="SELECT  sp.ids,sp.`name`,sp.proBh,sys_getCodeName(sp.typeIds) typeName,spp.outPrice   from  sb_product sp  "
					+"LEFT JOIN   sb_product_price  spp LEFT JOIN  sys_organization  so  on spp.priceIds=so.priceIds  on sp.ids=spp.productIds  " 
 					+"where   sp.proUnits=?  and  sp.proCapacity =?  and  spp.`status`='1'  and  sp.`status`='1' and  so.ids=? ";
		return  Product.dao.find(sql,proUnits,proCapacity,organIds);
	}
	/**
	 * 获取标准疗程
	 * @return
	 */
	public List<Product> getLiaoCheng(String proUnits,String proCapacity,String organIds){
		String  sql="SELECT  sp.ids,sp.`name`,sp.proBh,sys_getCodeName(sp.typeIds)  typeName,spp.outPrice   from  sb_product sp  "
					+"LEFT JOIN   sb_product_price  spp LEFT JOIN  sys_organization  so  on spp.priceIds=so.priceIds  on sp.ids=spp.productIds  " 
 					+"where   sp.proUnits=?  and  sp.proCapacity !=?  and  spp.`status`='1'  and  sp.`status`='1' and  so.ids=? ";
		return  Product.dao.find(sql,proUnits,proCapacity,organIds);
	}

}
